<template>
  <div>
    <input type="checkbox" v-model="all" />
    <span v-for="item in list" :key="item.id"
      >{{ item.name }}<input type="checkbox" v-model="item.done"
    /></span>
    <p>{{ full() }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      first: "z",
      last: "s",
      list: [
        { id: 1, name: "吃饭", done: false },
        { id: 2, name: "睡觉", done: true },
        { id: 3, name: "打豆豆", done: false },
      ],
    };
  },
  methods: {
    full() {
      return this.first + this.last;
    },
  },
  computed: {
    // full() {
    //   return this.first + this.last;
    // },
    all: {
      get() {
        return this.list.every((item) => item.done === true);
      },
      set(newVal) {
        return this.list.forEach((item) => (item.done = newVal));
      },
    },
  },
};
</script>

<style></style>
